﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using Athena;
using Athena.Plugins;
using WeifenLuo.WinFormsUI.Docking;
using Athena.Core;
using Athena.Tools;

namespace StochasticSimulator
{
    public class SimTool : INonVisualTool
    {
        public static Simulator simulator = new Simulator();

        public SimTool()
        {
            ToolManager.Instance.RegisterSimulationTool("Stochastic", this);
            if (ToolManager.Instance.Simulator == null)
                ToolManager.Instance.SelectSimulationTool(this,simulator);
            if (ToolManager.Instance.Analyzer == null)
                ToolManager.Instance.SelectAnalysisTool(this,simulator);
        }

        public override void SetupToolStrip(ToolStrip oStrip)
        {
            _oStrip = oStrip;
            ToolStripButton oButton = new ToolStripButton();            
            oButton.Text = "Stochastic";
            oButton.ToolTipText = "Gillespie algorithm with non-negative propensity enforced";
            oButton.Click += new EventHandler(SimulateButton_Pressed);
            _bHasContextMenuItems = false;
            _bHasMenuItems = false;
            _bRequiresNewToolWindow = false;
            oStrip.Items.Add(oButton);
        }

        public override bool HasMenuItems
        {
            get
            {
                return false;
            }
        }

        public override ToolManager.Order Order
        {
            get
            {
                return ToolManager.Order.FRONT;
            }
        }

        public void SimulateButton_Pressed(object sender, EventArgs e)
        {
            ToolManager.Instance.SelectSimulationTool(sender, simulator);
            ToolManager.Instance.StartSimulation();
        }
    }
}
